﻿using System.Collections;
using System.Collections.Generic;
using UnityEngine;

namespace NinjaToolbox.SubComponentModule
{
    public abstract class SubComponentBase : ISubComponent
    {
        protected SubComponentContext mContext;
        protected SubComponentModelBase mModel;


        public SubComponentModelBase GetModel() { return mModel; }

        protected virtual void SubComponent_Awake() { }
        protected virtual void SubComponent_OnEnable() { }
        protected virtual void SubComponent_Start() { }
        protected virtual void SubComponent_OnDisable() { }
        protected virtual void SubComponent_OnDestroy() { }
        protected virtual void SubComponent_Update() { }
        protected virtual void SubComponent_LateUpdate() { }
        protected virtual void SubComponent_FixedUpdate() { }

        #region --- ISubComponent Members ---

        void ISubComponent.Awake()
        {
            SubComponent_Awake();
        }

        void ISubComponent.FixedUpdate()
        {
            SubComponent_FixedUpdate();
        }

        void ISubComponent.LateUpdate()
        {
            SubComponent_LateUpdate();
        }

        void ISubComponent.OnDestroy()
        {
            SubComponent_OnDestroy();
        }

        void ISubComponent.OnDisable()
        {
            SubComponent_OnDisable();
        }

        void ISubComponent.OnEnable()
        {
            SubComponent_OnEnable();
        }

        void ISubComponent.Start()
        {
            SubComponent_Start();
        }

        void ISubComponent.Update()
        {
            SubComponent_Update();
        }

        void ISubComponent.ContextInitialization(SubComponentContext context)
        {
            mContext = context;
        }

        void ISubComponent.ModelInitialization(SubComponentModelBase model)
        {
            mModel = model;
        }
        #endregion
    }
}
